#include<bits/stdc++.h>
using namespace std;
int n,m,l,v,t;
int b[100010];
struct car{
    int d;
    int v;
    int a;
};
//vector<int>p[100010];
pair<int,int>q[100010];
int l1,r;
bool va(car a,int d){
    if(d<a.d)return 0;
    else {
        int a1=v*v-a.v*a.v;
        if(a1<a.a*2*(d-a.d))return 1;;
    }
    return 0;
}
bool check(car a,int o){
    bool f=0;
    int l1=(lower_bound(b,b+m,a.d)-b),r1=m;
    //int o;
    if(a.a>=0){
        while(l1<r1){
            int mid=(l1+r1)/2;
            if(va(a,b[mid])){
                r1=mid;
            }
            else{
                l1=mid+1;
            }
        }
        //cout<<o<<" "<<i<<endl;
        if(l1!=m){
            q[o].first=l1;
            q[o].second=m;
            return 1;

        }

    }

    else{
        while(l1<r1){
            int mid=(l1+r1)/2;
            if(va(a,b[mid])){
                l1=mid+1;
            }
            else{
                r1=mid;
            }
        }
        if(l1!=(lower_bound(b,b+m,a.d)-b)){
            l1--;
            q[o].first=(lower_bound(b,b+m,a.d)-b)+1;
            q[o].second=l1+1;
            return 1;
        }

    }
    return f;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    //freopen("detect2.in","r",stdin);
    cin>>t;
    while(t--){
        for(int i=0;i<100010;i++){
            q[i].first=0;
            q[i].second=0;
        }
        int ans1=0;
        l1=0;
        r=0;
        cin>>n>>m>>l>>v;
        int ans=0;
        car a[n];
        for(int i=0;i<n;i++){
            cin>>a[i].d>>a[i].v>>a[i].a;
        }
        for(int i=0;i<m;i++){
            cin>>b[i];
        }
        sort(b,b+m);
        for(int i=0;i<n;i++){
            if(check(a[i],i))ans++;
        }
        //sort(a,a+n,cmp);
        sort(q,q+n);
        //for(int i=0;i<n;i++){
        //    cout<<q[i].first<<" "<<q[i].second<<endl;
        //}
        for(int i=0;i<n;i++){
            if(q[i].first==0)continue;
            if(q[i].first>r||q[i].second<l1){
                //cout<<q[i].first<<" "<<q[i].second<<" "<<l1<<" "<<r<<endl<<endl;
                l1=q[i].first;
                r=q[i].second;
                ans1++;

            }
            else{
                l1=max(q[i].first,l1);
                r=min(q[i].second,r);
            }
            //cout<<l1<<" "<<r<<endl;
        }
        cout<<ans<<" "<<m-ans1<<endl;
    }
    return 0;
}
